﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace ZXthex.EditorUI
{
    public static class EUIStyles
    {
        private static GUIStyle _box;
        public static GUIStyle Box
        {
            get
            {
                if (_box == null)
                {
                    _box = new GUIStyle();
                    var tback = new Texture2D(8, 8);
                    for (int i = 0; i < 8; i++)
                        for (int j = 0; j < 8; j++)
                        {
                            if (i == 0 || j == 0
                                || i == 7 || j == 7)
                            {

                                tback.SetPixel(i, j, Color.black);
                            }
                            else
                            {
                            }
                        }
                    tback.Apply();
                    _box.normal.background = tback;
                    _box.border = new RectOffset(6, 6, 6, 6);
                }
                return _box;
            }
        }

        private static GUIStyle _button;
        public static GUIStyle Button
        {
            get
            {
                if (_button == null)
                {
                    _button = new GUIStyle();
                    var tback = new Texture2D(8, 8);
                    for (int i = 0; i < 8; i++)
                        for (int j = 0; j < 8; j++)
                        {
                            if (i == 0 || j == 0
                                || i == 7 || j == 7)
                            {

                                tback.SetPixel(i, j, Color.black);
                            }
                            else
                            {
                                tback.SetPixel(i, j, new Color(0.8f, 0.8f, 0.8f, 1));
                            }
                        }
                    tback.Apply();
                    _button.normal.background = tback;
                    tback = new Texture2D(8, 8);
                    for (int i = 0; i < 8; i++)
                        for (int j = 0; j < 8; j++)
                        {
                            if (i == 0 || j == 0
                                || i == 7 || j == 7)
                            {

                                tback.SetPixel(i, j, Color.black);
                            }
                            else
                            {
                                tback.SetPixel(i, j, new Color(0.6f, 0.6f, 0.6f, 1));
                            }
                        }
                    tback.Apply();
                    _button.active.background = tback;
                    _button.border = new RectOffset(6, 6, 6, 6);
                    _button.alignment = TextAnchor.MiddleCenter;
                }
                return _button;
            }
        }
    }
}
